/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var uniquePaths = function (m, n) {
  //创建状态数组
  const dp = Array.from({ length: m }, () => new Array(n).fill(0))

  //初始化第一行和第一列
  for (let i = 0; i < m; i++) {
    dp[i][0] = 1
  }
  for (let j = 0; j < n; j++) {
    dp[0][j] = 1
  }

  //求非第一第一列的状态
  for (let i = 1; i < m; i++) {
    for (let j = 1; j < n; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
    }
  }
  //返回结果
  return dp[m - 1][n - 1]
};

console.log(uniquePaths(3, 7))
